<template>
	<div class="box_table">
		<el-table :data="data" height="90%" style="width: 100%">
			<el-table-column v-for="(item,index) in datatitle" :key='index' :prop="item.name2" :label="item.name"/>
			
			<el-table-column label="操作" width='280' v-if='this.$route.path!="/bill"'>
			      <template #default="scope">
			        <el-button size="small" type="primary" @click="lookxq(scope.$index, scope.row)"
			          >查看详情</el-button>
					<el-button size="small" type="success" @click="edit(scope.$index, scope.row)"
					 v-if='this.$route.path!="/adminmanage"&&this.$route.path!="/rolemanage"'
					  >修改</el-button>
					<el-button
					    size="small"
					    type="warning"
						v-if='this.$route.path!="/rolemanage"'
					    @click="handleDelete(0,scope.$index, scope.row)"
					    >{{scope.row.isdel==1?'冻结':'启用'}}</el-button>
			        <el-button
			          size="small"
			          type="danger"
					  v-if='this.$route.path!="/adminmanage"'
			          @click="handleDelete(1,scope.$index, scope.row)"
			          >删除</el-button>
			      </template>
			    </el-table-column>
		</el-table>
		<div class="footer_table">
			<div class="total_number">
				总共{{total}}条数据
			</div>
			<el-pagination
			      v-model:currentPage="currentPage1"
			      :page-size="10"
			      small
			      layout="prev, pager, next"
			      :total="total"
			      @size-change="handleSizeChange"
			      @current-change="handleCurrentChange"
			    />
		</div>
		<tipsbox tipstitle="警告" :tipscont='tipscont' :centerDialogVisible='showfalg' @cancel='cancel' @sure='sure'></tipsbox>
	</div>
	
</template>

<script>
	export default {
	props:['data','datatitle','total'],
	  data() {
	    return {
			showfalg:false,//显示删除提示框,
			tipscont:'您确定要删除该数据吗？',
			id:'',
			isdel:''
		}
	  },
	  methods:{
		  handleDelete(flag,index,item){//flag 0为冻结，1为删除
			this.id=item.id?item.id:item.hut_id?item.hut_id:item.admin_id
			if(flag==0){
				this.isdel=item.isdel==1?'2':'1'
				if(item.isdel==1){
					this.tipscont='您确定要冻结该数据吗？'
				}else{
					this.tipscont='您确定要启用该数据吗？'
				}
				
			}else{
				this.isdel=item.isdel
				this.tipscont='您确定要删除该数据吗？'
			}
			  this.showfalg = true
		  },
		  sure(){//提示框点击确定按钮
			  let type=''
			  if(this.tipscont=='您确定要删除该数据吗？'){
				  type=2
			  }else{
				  type=1
			  }
			  let obj = {type:type,status:this.isdel,id:this.id}
			  this.$emit('deleteAnddj',obj)
			 
			  this.cancel()
		  },
		  cancel(){
			  this.showfalg = false
		  },
		  lookxq(index,item){
			  let id =item.id?item.id:item.hut_id
			  if(id){
				  this.$emit('lookxq',id)
			  }else{
				  this.$emit('lookxq',item)
			  }
			  
		  },
		  edit(index,item){
			  let id =item.id?item.id:item.hut_id
			  this.$emit('edit',id)
		  },
		  handleSizeChange(val){
			  console.log(val)
		  },
		  handleCurrentChange(val){
			  this.$emit('fanye',val)
		  }
	  },
	  watch: {
	        data(newVal,oldVal){
	        }
		},
	  created() {
	  }
	}
</script>

<style lang="less" scoped>
	.box_table{
		margin-top: 4%;
		background: #fff;
		height: 80%;
		padding: 0.5rem;
		border-radius: 1%;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		.footer_table{
			display: flex;
			align-items: center;
			justify-content: flex-end;
			.total_number{
				color: #c0c0c0;
			}
		}
		.el-pagination{
			display: flex;
			    justify-content: flex-end;
		}
		/deep/ .el-table tr{
			height: 60px;
		}
	}
</style>
